Skip to content

Чеботарев - Project 3# Quest#9

Open
mxchbot wants to merge 8 commits intodemologin:mainfrom
mxchbot:chebotarev
Open

Чеботарев - Project 3# Quest#9
mxchbot wants to merge 8 commits intodemologin:mainfrom
mxchbot:chebotarev

Conversation

@mxchbot
Copy link

@mxchbot mxchbot commented Feb 3, 2026

No description provided.

@mxchbot mxchbot changed the title Project 3# Quest Чеботарев - Project 3# Quest Feb 3, 2026
Copy link
Owner

@demologin demologin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Общий вывод по проекту

Проект демонстрирует хорошее владение базовыми принципами Java и архитектурными паттернами. Использование Command pattern для обработки запросов и Mockito для тестов — это отличный уровень. Однако стоит уделить больше внимания безопасности (валидация входных данных) и чистоте кода (Dependency Injection вместо поиска в репозитории объектов).

Итоговая оценка: A


private int getSelectedQuestIndex(HttpServletRequest req) {
String questIndexString = req.getParameter(Parameter.QUEST_INDEX);
return Integer.parseInt(questIndexString);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Метод Integer.parseInt может выбросить NumberFormatException, если параметр отсутствует или не является числом. Следует добавить валидацию входных данных. [ERROR]


private int getSelectedNextNodeId(HttpServletRequest req) {
String nextNodeIdString = req.getParameter(Parameter.NEXT_NODE_ID);
return Integer.parseInt(nextNodeIdString);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Прямое приведение строки из параметров запроса к числу без проверки на null или формат является потенциальным источником RuntimeException. [ERROR]

ObjectMapper mapper = ObjectRepository.find(ObjectMapper.class);
Quest quest = mapper.readValue(req.getReader(), Quest.class);
QuestService questService = ObjectRepository.find(QuestService.class);
questService.saveQuest(quest);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Результат сохранения квеста игнорируется. Если saveQuest возвращает путь к файлу, возможно, его стоит использовать для логирования или информирования пользователя. [INFO]

QuestService questService = ObjectRepository.find(QuestService.class);
questService.saveQuest(quest);
} catch (IOException e) {
throw new RuntimeException(e);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Оборачивание IOException в RuntimeException без контекста затрудняет отладку. Рекомендуется использовать пользовательские исключения или информативные сообщения. [WARNING]

default String doPost(HttpServletRequest request) {
public String doPost(HttpServletRequest req) {
return getView();
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Логика преобразования CamelCase в kebab-style может быть упрощена с использованием регулярных выражений Java 21. [INFO]

@@ -32,6 +33,4 @@ private static String convertCamelCaseToKebabStyle(String string) {
? snakeName.substring(1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вспомогательный метод преобразования строк стоит вынести в отдельный утилитный класс, чтобы не загромождать базовый абстрактный класс. [INFO]

String view = nextStage.doGet(req, servlet);

assertEquals(Go.RESULT, view);
assertEquals(1, statistics.getVictoriesCount());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тест проверяет сразу несколько сценариев (победа, поражение, обычный ход) в одном методе. Стоит разделить на разные тестовые методы. [INFO]

try {
req.setCharacterEncoding("UTF-8");
ObjectMapper mapper = ObjectRepository.find(ObjectMapper.class);
Quest quest = mapper.readValue(req.getReader(), Quest.class);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Чтение всего тела запроса через getReader() и маппинг в объект может упасть с ошибкой памяти при очень больших файлах квестов. [WARNING]

public class MainMenu extends Command {

@Override
public String doGet(HttpServletRequest req, HttpServlet servlet) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Метод не содержит логирования. Для Senior уровня важно отслеживать действия пользователя (например, вход в главное меню). [INFO]

}

private int getSelectedNextNodeId(HttpServletRequest req) {
String nextNodeIdString = req.getParameter(Parameter.NEXT_NODE_ID);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Имя параметра NEXT_NODE_ID лучше вынести в константу класса Parameter для исключения опечаток. [INFO]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants